package com.lanou.dllo.shise.com.lanou.dllo.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.lanou.dllo.shise.com.lanou.dllo.entity.FoodZineBean;
import com.lanou.dllo.shise.com.lanou.dllo.fragment.Carefully_choseFragment;
import com.lanou.dllo.shise.com.lanou.dllo.fragment.Close_attentionFragment;
import com.lanou.dllo.shise.com.lanou.dllo.fragment.TopStoryFragment;

import java.util.List;

/**
 * Created by dllo on 15/11/1.
 */
public class ViewPagerAdapter extends FragmentPagerAdapter{
    private List<FoodZineBean.ResultEntity> food;
    public void addData(List<FoodZineBean.ResultEntity> datas){
        food = datas;
        notifyDataSetChanged();
    }
    public ViewPagerAdapter(FragmentManager fm) {
        super(fm);
    }

    @Override
    public Fragment getItem(int position) {
        FoodZineBean.ResultEntity f = food.get(position);
        String title = f.getTitle();
        String imgurl = f.getPicture_url();
        return TopStoryFragment.getInstance(title, imgurl);
    }

    @Override
    public int getCount() {
        return food != null && food.size() > 0 ? food.size() : 0;
    }
}
